﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="roll_file.aspx.cs" Inherits="AnyOffice.general.rms.roll_lend.roll_file" %>

<%@ Register TagPrefix="Webdiver" Namespace="Webdiver" Assembly="AspnetPager" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
		<script language="JavaScript">
		function lend_file(file_id,page,roll_id,rollpage)
		{
			msg='确认要借阅该项文件么？';
			if(window.confirm(msg))
			{
				URL="lend.aspx?file_id="+file_id+"&roll_id="+roll_id+"&page="+page+"&rollpage="+rollpage;
				window.location=URL;
			}
		}
function open_file(file_id)
{
 URL="read_file0.aspx?file_id="+file_id;
 myleft=(screen.availWidth-500)/2;
 mytop=150
 mywidth=550;
 myheight=400;
 window.open(URL,"read_roll","height="+myheight+",width="+mywidth+",status=1,toolbar=no,menubar=no,location=no,scrollbars=yes,top="+mytop+",left="+myleft+",resizable=yes");
}

 function CheckAll( checkAllBox )                         
 {                                                                  
 var frm = document.Form1;                               
  var ChkState=checkAllBox.checked;                   
  for(i=0;i< frm.length;i++)                                 
  {                                                                 
         e=frm.elements[i];                                   
        if(e.type=='checkbox' && e.name.indexOf('FileId') != -1)
            e.checked= ChkState ;                        
  }                                                               
 }                                                                
                           
function CheckChanged()                                   
{                                                                   
  var frm = document.Form1;                              
  var boolAllChecked;                                         
  boolAllChecked=true;                                       
  for(i=0;i< frm.length;i++)                                 
  {                                                                 
    e=frm.elements[i];                                        
  if ( e.type=='checkbox' && e.name.indexOf('FileId') != -1 )
      if(e.checked== false)                                  
      {                                                             
         boolAllChecked=false;                               
         break;                                                    
      }                                                              
  }                                                                  
  for(i=0;i< frm.length;i++)                                  
  {                                                                  
    e=frm.elements[i];                                         
    if ( e.type=='checkbox' && e.name.indexOf('checkAll') != -1 )
    {                                                            
      if( boolAllChecked==false)                         
         e.checked= false ;                                
         else                                                    
         e.checked= true;                                  
      break;                                                    
    }                                                             
   }                                                              
 }
 
 function lend_all()
{
	var checkNums=0;
	var checkList = document.getElementsByTagName("input");
	for(i=0;i<checkList.length;i++)
	{
		if((checkList[i].type == "checkbox") && (checkList[i].id != "checkAll"))
		{
			if(checkList[i].checked)
				checkNums++;
		}
	}
	
	if(checkNums==0)
	{
		alert("要借阅文件，请至少选择其中一个。");						
		return false;
	}

	msg='确认要借阅已选中的文件么？';
	if(window.confirm(msg))
		return true;
	else
		return false;
}                                                       
		</script>
	</HEAD>
	<body class="bodycolor" topMargin="5">
		<form id="Form1" method="post" runat="server">			
			<asp:panel id="pnlMain" runat="server">
			<table class="small" cellSpacing="0" cellPadding="3" width="100%" border="0">
				<tr>
					<td class="Big" width="40%">
						<img src="/images/notify_open.gif" align="absMiddle"><span class="big3"> 查看文件</span>
					</td>
					<td>
					</td>
					<td vAlign="bottom" width="60%">
						<asp:literal id="litNavCount" runat="server"></asp:literal>&nbsp;&nbsp;&nbsp;&nbsp;
						<asp:literal id="litNavPager" runat="server"></asp:literal>
					</td>
				</tr>
			</table>
			<BR>
				<TABLE class="small" cellSpacing="1" cellPadding="3" width="100%" bgColor="#000000" border="0">
					<TR class="TableHeader">
						<TD noWrap align="center">选择</TD>
						<TD noWrap align="center">文件号</TD>
						<TD noWrap align="center">文件标题</TD>
						<TD noWrap align="center">密级</TD>
						<TD noWrap align="center">发文单位</TD>
						<TD noWrap align="center">发文日期</TD>
						<TD noWrap align="center">所属案卷</TD>
						<TD noWrap align="center">操作</TD>
					</TR>
					<asp:Repeater id="rptRmsFile" runat="server">
					<ItemTemplate>
						<tr class="TableLine1">
							<td align="center"><input type="checkbox" runat="server" id="FileId" onclick="CheckChanged();" name="FileId" value='<%#Eval("FileId")%>' /></td>
							<td align="center"><a href="javascript:open_file('<%#Eval("FileId")%>');"><%#Eval("FileCode")%></a></td>
							<td align="center"><%#Eval("FileTitle")%></td>
							<td align="center"><%#Eval("Secret") != DBNull.Value ? GetCodeName(Eval("Secret").ToString(), "Secret") : ""%></td>
							<td align="center"><%#Eval("SendUnit")%></td>
							<td align="center"><%#Eval("SendDate") != DBNull.Value ? Convert.ToDateTime(Eval("SendDate").ToString()).ToString("yyyy-MM-dd") : ""%></td>
							<td align="center"><%#Eval("RollId") != DBNull.Value ? GetRollName(Convert.ToInt32(Eval("RollId").ToString())) : ""%></td>
							<td align="center">
								<a href="javascript:lend_file('<%#Eval("FileId")%>','<%=ViewState["CurrentPage"]%>','<%#Eval("RollId")%>','<%=ViewState["RollPage"]%>');">借阅</a>
							</td>					
						</tr>
					</ItemTemplate>
					<AlternatingItemTemplate>
					<tr class="TableLine2">
							<td align="center"><input type="checkbox" runat="server" id="FileId" onclick="CheckChanged();" name="FileId" value='<%#Eval("FileId")%>' /></td>
							<td align="center"><a href="javascript:open_file('<%#Eval("FileId")%>');"><%#Eval("FileCode")%></a></td>
							<td align="center"><%#Eval("FileTitle")%></td>
							<td align="center"><%#Eval("Secret") != DBNull.Value ? GetCodeName(Eval("Secret").ToString(), "Secret") : ""%></td>
							<td align="center"><%#Eval("SendUnit")%></td>
							<td align="center"><%#Eval("SendDate") != DBNull.Value ? Convert.ToDateTime(Eval("SendDate").ToString()).ToString("yyyy-MM-dd") : ""%></td>
							<td align="center"><%#Eval("RollId") != DBNull.Value ? GetRollName(Convert.ToInt32(Eval("RollId").ToString())) : ""%></td>
							<td align="center">
								<a href="javascript:lend_file('<%#Eval("FileId")%>','<%=ViewState["CurrentPage"]%>','<%#Eval("RollId")%>','<%=ViewState["RollPage"]%>');">借阅</a>
							</td>					
						</tr>
					</AlternatingItemTemplate>
					</asp:Repeater>
					<TR class="TableControl">
						<TD colSpan="9">
							<TABLE class="small" cellSpacing="0" cellPadding="0" width="100%">
								<TR>
									<TD>&nbsp;&nbsp;<INPUT id="checkAll" onclick="CheckAll(this);" type="checkbox" name="checkAll">
										全部选中&nbsp;&nbsp;
										<asp:Button id="btnLend" runat="server" CssClass="SmallButton" Text="批量借阅" EnableViewState="False"></asp:Button>
									</TD>
									<TD align="right">
										<WEBDIVER:ASPNETPAGER id="AspNetPager1" runat="server" CssClass="small1" InputBoxClass="SmallInput" SubmitButtonClass="SmallButton"
											Font-Size="10pt" OnPageChanged="ChangePage" HorizontalAlign="Right" ShowCustomInfoSection="left" ShowInputBox="Always"
											SubmitButtonText="转到" NumericButtonTextFormatString="[{0}]" UrlPaging="True" CustomInfoSectionWidth="35%"
											PagingButtonSpacing="0" ImagePath="../images" ButtonImageNameExtension="n" CpiButtonImageNameExtension="r"
											DisabledButtonImageNameExtension="g" PageSize="10" AlwaysShow="True"></WEBDIVER:ASPNETPAGER></WEBDIVER:ASPNETPAGER></TD>
								</TR>
							</TABLE>
						</TD>
					</TR>
				</TABLE>
				<br>
				<center><INPUT class="BigButton" onclick="location='search.aspx?page=<%=ViewState["RollPage"]%>'" type="button" value="返回"></center>
			</asp:panel>
			<asp:literal id="litMessage" runat="server"></asp:literal>			
		</form>
	</body>
</HTML>
